package basic_1023;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scanner=new Scanner(System.in);
		
		String badKeys=scanner.next();
		String input=scanner.next();
	
		scanner.close();
		
		String output=input;
		List<String>badlist=new ArrayList<String>();
		
		boolean isShiftBad=false;
		for(char c :badKeys.toCharArray()) {
			
			if(badlist.contains(""+c)) {
				continue;
			}
			if(c=='+') {
				isShiftBad=true;
				continue;
			}
			if(!isShiftBad&&((c>='a'&&c<='z')||(c>='A'&&c<='Z'))) {
				badlist.add((""+c).toUpperCase());
			}
			
			badlist.add((""+c).toLowerCase());
		}
		
		if(isShiftBad) {
			for(char c='A';c<='Z';c++) {
				output=output.replace(""+c, "");
				badlist.remove(""+c);
			}
		}
		

		for(String c:badlist) {
			output=output.replace(c, "");
		}
		
		System.out.println(output);
	}
}
